<?php

namespace app\common\model;

use think\Model;

class AppDownload extends Model
{
    // 表名
    protected $name = 'app_download';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'force_text',
	    'type_text'
    ];
    
	const FORCE_Y = 1;
	const FORCE_N = 0;
	
	public static $_force = [
		self::FORCE_Y => '是',
		self::FORCE_N => '否'
	];
    
    public function getForceList()
    {
    	return self::$_force;
    }


    public function getForceTextAttr($value, $data)
    {
        $value = $value ? $value : $data['force'];
        $list = $this->getForceList();
        return isset($list[$value]) ? $list[$value] : '';
    }

	const TYPE_ANDROID = 1;
    const TYPE_IOS = 2;
    const TYPE_SMALL = 3;

    public static $typeList = [
        self::TYPE_ANDROID => '安卓',
	    self::TYPE_IOS => '苹果',
	    self::TYPE_SMALL => '小程序'
    ];

    public function getTypeTextAttr($value, $data) {
    	$value = $value?:$data['app_type'];
    	$list = self::$typeList;
    	return isset($list[$value]) ? $list[$value] : '';
    }
}
